/*
 * CS_SOCIAL_INVITE_NOAPP_FRIEND_SM.cpp
 *
 *  Created on: 2013. 6. 4.
 *      Author: the2
 */


#include "../../Command.h"
#include "../../User.h"
#include "../../Proxy.h"
#include "../../../../protocol/iFriends.h"
#include "../../NResource/Static.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_SOCIAL_INVITE_NOAPP_FRIEND_SM(User * pUser, ::Network::Packet * pPacket)
{
	PREPARE_PACKET;

	InviteNoAppSyn msg;
	Toolkit::Str<MAX_SOCIALID_LEN> user_id;
	*pPacket >> user_id;

	msg.user_id = user_id.c_str();

	if( msg.user_id.size() <= 0 )
	{
		::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();

		pAck->MsgCat("%2d%c%c", ACK_UNKNOWN_ERROR, 1, 0);
		pAck->MakePacket(CMD_SC_SOCIAL_INVITE_NOAPP_FRIEND_SM);
		pUser->Send(pAck);
		return;
	}

	NResource::BalanceResource * balanceResource = NResource::Static::InstancePtr()->GetBalance();
	msg.heart_count_max = balanceResource->GetValue(pUser, EM_FRIEND_POINT_MAX);

	NResource::SocialRewardResource * socialReward = NResource::Static::InstancePtr()->GetSocialReward();
	NResource::SocialRewardData::Flyweight * rewardData = socialReward->GetFly(pUser, NResource::SocialRewardData::InviteNoAppFriend);

	msg.send_heart_count = rewardData->_SEND_REWARD * rewardData->_IS_EVENT;
	msg.recv_heart_count = rewardData->_RECV_REWARD * rewardData->_IS_EVENT;
	msg.msg_type = rewardData->_MSG_TYPE;

	::ProjectZ::NProxy::SendFriendsServer(pUser->GetUserSeq(), msg);
}

} /*NCommand*/ } /*ProjectZ*/

